/* ----------------------------------------------------------------------
*
* Copyright (C) 2024 XiaoFei. All rights reserved.
*
* $file:        XiaoFei_ComplexMath.h
* $Date:        21-October-2024
* $Revision:    V1.2
* $Project:     XiaoFei DSP Library
*
* -------------------------------------------------------------------- */

#ifndef __XiaoFei_ComplexMath_H
#define __XiaoFei_ComplexMath_H

#ifndef My_ERROR
#define My_ERROR                    0.00000001
#endif
#ifndef My_PI
#define My_PI                       3.14159265
#endif
#ifndef My_EXP_2
#define My_EXP_2                    7.38905609
#endif
#ifndef My_EXP_5
#define My_EXP_5                    148.41315915
#endif
#ifndef My_LOG_2
#define My_LOG_2                    0.69314718
#endif
#ifndef My_LOG_10
#define My_LOG_10                   2.30258509
#endif

#ifndef ResStatus_TypeDef_def
#define ResStatus_TypeDef_def
typedef enum
{ 
    Error       = 0x00,         /*!< The calculation failed */
    Success     = 0x01          /*!< The calculation was successful */
}ResStatus_TypeDef;
#endif

#ifndef Complex_TypeDef_def
#define Complex_TypeDef_def
typedef struct
{ 
    double Real ;               /*!< The real part of the complex number */
    double Imag ;               /*!< The imaginary part of the complex number */
}Complex_TypeDef;
#endif

/* 
* @function:    My_ComplexAdd
* @parameter:   [in]    *a              An addition to complex additions.
* @parameter:   [in]    *b              Another addition to complex additions.
* @parameter:   [out]   *ans            The result of complex additions.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_ComplexAdd(Complex_TypeDef* a, Complex_TypeDef* b, Complex_TypeDef* ans);

/* 
* @function:    My_ComplexSub
* @parameter:   [in]    *a              The subtracted number of complex subtraction.
* @parameter:   [in]    *b              The subtraction of complex subtraction.
* @parameter:   [out]   *ans            The result of complex subtraction.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_ComplexSub(Complex_TypeDef* a, Complex_TypeDef* b, Complex_TypeDef* ans);

/* 
* @function:    My_ComplexMul
* @parameter:   [in]    *a              A multiplier for complex multiplication.
* @parameter:   [in]    *b              Another multiplier for complex multiplication.
* @parameter:   [out]   *ans            The result of complex multiplication.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_ComplexMul(Complex_TypeDef* a, Complex_TypeDef* b, Complex_TypeDef* ans);

/* 
* @function:    My_ComplexDiv
* @parameter:   [in]    *a              The dividend number of complex division.
* @parameter:   [in]    *b              The divisor of complex division.
* @parameter:   [out]   *ans            The result of complex division.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_ComplexDiv(Complex_TypeDef* a, Complex_TypeDef* b, Complex_TypeDef* ans);

/* 
* @function:    My_ComplexConj
* @parameter:   [in]    *a              The original complex number of conjugate.
* @parameter:   [out]   *ans            The result of conjugation of complex numbers.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_ComplexConj(Complex_TypeDef* a, Complex_TypeDef* ans);

/* 
* @function:    My_ComplexMagn
* @parameter:   [in]    *a              The original complex number of Magnitude.
* @parameter:   [out]   *ans            The Magnitude of the complex numbers.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_ComplexMagn(Complex_TypeDef* a, double* ans);

/* 
* @function:    My_ComplexPhas
* @parameter:   [in]    *a              The original complex number of principal.
* @parameter:   [out]   *ans            The principal phase of the complex numbers.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_ComplexPhas(Complex_TypeDef* a, double* ans);

/* 
* @function:    My_ComplexExp
* @parameter:   [in]    *a              The original complex number of Exponential.
* @parameter:   [out]   *ans            The Exponential of the complex numbers.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_ComplexExp(Complex_TypeDef* a, Complex_TypeDef* ans);

/* 
* @function:    My_ComplexLog
* @parameter:   [in]    *a              The original complex number of Logarithmic.
* @parameter:   [out]   *ans            The Logarithmic of the complex numbers.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_ComplexLog(Complex_TypeDef* a, Complex_TypeDef* ans);

/* 
* @function:    My_ComplexCos
* @parameter:   [in]    *a              The original complex number of Cosine.
* @parameter:   [out]   *ans            The Cosine of the complex numbers.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_ComplexCos(Complex_TypeDef* a, Complex_TypeDef* ans);

/* 
* @function:    My_ComplexSin
* @parameter:   [in]    *a              The original complex number of Sinusoidal.
* @parameter:   [out]   *ans            The Sinusoidal of the complex numbers.
* @return:      Successes or failures of the results of the calculations.
*/
ResStatus_TypeDef My_ComplexSin(Complex_TypeDef* a, Complex_TypeDef* ans);

#endif

